package com.zp.mvppractice.mvp2;

import android.os.Bundle;
import android.view.View;

/**
 * Created by izp on 2017/7/10.
 */

public abstract class DataBindFragment<D extends Delegate> extends PresentFragment<D> {
    protected DataBinder binder;

    /**
     * @return
     * 后代 构造一个实例
     */
    public abstract DataBinder getDataBinder();

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        binder = getDataBinder();
    }

    public <M extends DataModel> void notifyModelChanged(M data) {
        if (binder != null)
            binder.viewBindModel(viewDelegate, data);
    }
}
